<div class="box box-info">
    <div class="box-header with-border">
        <h3 class="box-title">用户提现</h3>
        <div class="box-tools">
            <div class="btn-group pull-right" style="margin-right: 10px">
                <a href="{{ route('withdraw.index') }}" class="btn btn-sm btn-default"><i class="fa fa-list"></i> 列表</a>
            </div>
        </div>
    </div>

    <div class="box-body">
        <table class="table table-bordered">
            <tbody>
            <tr>
                <td>开户名</td>

                <td>{{$userWithdraw->user_name}}</td>
            </tr>
            <tr>
                <td>银行账号</td>
                <td>{{$userWithdraw->bank_code}}</td>
            </tr>
            <tr>
                <td>银行类型</td>
                <td><img src="{{getBankImg($userWithdraw->bank_code)}}"></td>
            </tr>
            <tr>
                <td>提现金额</td>
                <td>{{$userWithdraw->price}}</td>
            </tr>
            <tr>
                <td>状态</td>
                <td>{{\App\UserWithdraw::$statusMap[$userWithdraw->status]}}</td>
            </tr>
            </tbody>
            @if($userWithdraw->status==\App\UserWithdraw::STATUS_PENDING)
            <tr>
                <td colspan="4">
                    <div class="form-inline">
                        <!-- 别忘了 csrf token 字段 -->
                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                        <input type="hidden" id="withdraw_id" value="{{$userWithdraw->id}}">
                        <div class="form-group">
                            <label for="express_company" class="control-label">备注</label>
                            <textarea type="text" id="result_message" name="result_message"  class="form-control" placeholder="备注">
                            </textarea>
                        </div>

                        <button type="button" class="btn btn-success" onclick="submit()" id="ship-btn">自动打款</button>
                        <button type="button" class="btn btn-success" onclick="people()" id="ship-btn">人工打款</button>
                        <button type="button" class="btn btn-warning" onclick="refuse()" id="ship-btn">驳回</button>
                    </div>
                </td>
            </tr>
                @else
                <tr>
                </tr>

            @endif
        </table>


    </div>
</div>
<script type="text/javascript" src="{{asset('js/layer/layer/layer.js')}}"></script>
<script>
    var withdraw_id=$("#withdraw_id").val();
    var result_message=$("#result_message").html();
    function submit(){

        layer.confirm('是否确定自动打款', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.get('/admin/withdraw/submit',{withdraw_id:withdraw_id,result_message:result_message},function(data){
                if(data.code=='error'){
                    layer.msg(data.message, {icon: 1});
                }else{
                    layer.msg(data.message,{icon:1});
                    window.location.href='';
                }
            });

        }, function(){
            return '';
        });
    }
    function people(){

        layer.confirm('是否确定人工打款', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.get('/admin/withdraw/people',{withdraw_id:withdraw_id,result_message:result_message},function(data){
                if(data.code=='error'){
                    layer.msg(data.message, {icon: 1});
                }else{
                    layer.msg(data.message,{icon:1});
                    window.location.href='';
                }
            });

        }, function(){
            return '';
        });
    }
    function refuse(){
        layer.confirm('是否拒绝打款', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.get('/admin/withdraw/refuse',{withdraw_id:withdraw_id,result_message:result_message},function(data){
                if(data.code=='error'){

                    layer.msg(data.message, {icon: 1});
                }else{
                    layer.msg(data.message,{icon:1});
                    window.location.href='';
                }
            });

        }, function(){
            return '';
        });
    }
</script>